package com.leihao.product.controller;

import com.leihao.common.core.domain.R;
import com.leihao.product.domian.ServiceGuarantee;
import com.leihao.product.service.ServiceGuaranteeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("serviceGuarantee")
public class ServiceGuaranteeController {
    @Autowired
    private ServiceGuaranteeService serviceGuaranteeService;

    /**
     * 添加服务保证
     * @param serviceGuarantee
     * @return
     */
    @PostMapping("add")
    public R add(@RequestBody ServiceGuarantee serviceGuarantee) {
        serviceGuaranteeService.add(serviceGuarantee);
        return R.ok(null,"添加成功");
    }

    /**
     * 逻辑删除
     * @param serviceGuaranteeId
     * @return
     */
    @DeleteMapping("delete/{serviceGuaranteeId}")
    public R delete(@PathVariable Integer serviceGuaranteeId) {
        serviceGuaranteeService.delete(serviceGuaranteeId);
        return R.ok(null,"删除成功");
    }

    /**
     * 查询所有服务保证
     * @return
     */
    @GetMapping("findAll")
    public R<List<ServiceGuarantee>> findAll() {
        List<ServiceGuarantee> all = serviceGuaranteeService.findAll();
        return R.ok(all,"查询成功");
    }

    /**
     * 修改服务保证
     * @param serviceGuarantee
     * @return
     */
    @PutMapping("update")
    public R update(@RequestBody ServiceGuarantee serviceGuarantee) {
        serviceGuaranteeService.update(serviceGuarantee);
        return R.ok(null,"修改成功");
    }
}
